import java.util.*;
public class ShiCi {
    public static void main(String[] args) {
        StringBuffer s=new StringBuffer("汉皇重色思倾国御宇多年求不得杨家有女初长成养在深闺人未识" +
                "天生丽质难自弃一朝选在君王侧回眸一笑百媚生六宫粉黛无颜色" +
                "春寒赐浴华清池温泉水滑洗凝脂侍儿扶起娇无力始是新承恩泽时" +
                "云鬓花颜金步摇芙蓉帐暖度春宵春宵苦短日高起从此君王不早朝" +
                "承欢侍宴无闲暇春从春游夜专夜后宫佳丽三千人三千宠爱在一身" +
                "金屋妆成娇侍夜玉楼宴罢醉和春姊妹弟兄皆列士可怜光采生门户" +
                "遂令天下父母心不重生男重生女骊宫高处入青云仙乐风飘处处闻" +
                "缓歌慢舞凝丝竹尽日君王看不足渔阳鼙鼓动地来惊破霓裳羽衣曲" +
                "九重城阙烟尘生千乘万骑西南行");
        int x=s.length()/7;
        int y=s.length()/14;
        for(int i=0;i<x;i++){
            s.insert((i+1)*7+i,',');
        }

        for(int i=0;i<y;i++){
            s.setCharAt((i+1)*15+i,'.');
        }

        int z=s.length()/16;
        for(int i=0;i<z;i++){
            s.insert((i+1)*16+i,'\n');
        }
        System.out.println(s);
        System.out.print("请输入需要检索的单词:");
        Scanner sc = new Scanner(System.in); //输入检索的单词
        String word = sc.next();
        int ind=0;
        int t=0;
        while(s.indexOf(word,ind)>=0){
            t++;
            ind=s.indexOf(word,ind)+word.length();
        }
        System.out.println(word+"出现的次数为:"+t);
    }
}